<!DOCTYPE html>
<html>

<head>
  <meta charset="utf-8">
  <title></title>
</head>

<body>
  <script type="text/javascript">
    // 利用则表达式,把对象中的空值''改为null
    let obj = {
      a: 1,
      b: '',
      c: "空字符串改为null"
    }
    console.log(obj, '修改之前的obj')
    let itemList = JSON.stringify(obj)
    let result = itemList.replace(/""/g, "null");
    obj = JSON.parse(result)
    console.log(obj, '修改之后的obj')
  </script>
</body>

</html>